package com.lb.undertow.controller;

import com.lb.undertow.pojo.User;
import com.lb.undertow.setting.fanout.FanoutSender;
import com.lb.undertow.setting.hello.HelloSender;
import com.lb.undertow.setting.many.HelloSender1;
import com.lb.undertow.setting.many.HelloSender2;
import com.lb.undertow.setting.object.ObjectSender;
import com.lb.undertow.setting.topic.TopicSender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 001030
 */
@RestController
public class IndexController {

    @Autowired
    private HelloSender helloSender;

    @Autowired
    private HelloSender1 helloManySender;

    @Autowired
    private HelloSender2 helloSender2;

    @Autowired
    private ObjectSender objectSender;

    @Autowired
    private TopicSender topicSender;

    @Autowired
    private FanoutSender fanoutSender;


    @GetMapping("/sendMessage")
    public String sendMessage(){
        helloSender.sendMessage();
        return "send success";
    }


    @GetMapping("/sendMessage2")
    public String sendManyMessage(){
        helloManySender.sendMessage(1);
        helloSender2.send(1);
        return "send success";
    }

    @GetMapping("/sendMessage3")
    public String sendMessage3(){
        objectSender.send(User.builder().id(1L).name("李斌").build());
        return "send success";
    }

    @GetMapping("/sendMessage4")
    public String sendMessage4(){
        topicSender.send();
        topicSender.send1();
        topicSender.send2();
        return "send success";
    }

    @GetMapping("/sendMessage5")
    public String sendMessage5(){
        fanoutSender.send();
        return "send success";
    }

}
